#! /bin/bash
CODE_BASE_DIR=/root/code/mate-cloud/
DEPLOY_BASE_DIR=/usr/local/deploy/mate-cloud


echo "kill process..."

kill -9 `ps -ef | grep -w "mate-gateway.jar" | grep -v "grep" | awk '{print $2}'`
kill -9 `ps -ef | grep -w "mate-uaa.jar" | grep -v "grep" | awk '{print $2}'`
kill -9 `ps -ef | grep -w "mate-system.jar" | grep -v "grep" | awk '{print $2}'`
kill -9 `ps -ef | grep -w "mate-component.jar" | grep -v "grep" | awk '{print $2}'`


sleep 10s


echo "pull code..."
cd ${CODE_BASE_DIR}

echo "checkout code..."

#git checkout dev
#git pull origin dev
#git checkout test
#git merge dev
#git push origin test

echo "maven clean install..."
mvn clean install -Dmaven.javadoc.skip=true -Dgpg.skip


cd ${DEPLOY_BASE_DIR}
dateDir=$(date +%Y%m%d_%H%M%S)
mv logs logs-${dateDir}
mkdir -p logs

sh mate-gateway.sh
echo "start mate-gateway"

sh mate-uaa.sh
echo "start mate-uaa"

sh mate-system.sh
echo "start mate-system"

sh mate-component.sh
echo "start mate-component"



